home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CD-ROM Today - The Disc! 5
/
CD-ROM Today - The Disc (Issue 5)(November 1994).ISO
/
mac
/
Mac shareware
/
Education
/
RLaB
/
help
/
fvscope
< prev
next >
Wrap
Text File
|
1994-09-21
|
2KB
|
54 lines
fvscope:
Syntax: fvscope ( FNAME )
fvscope ( FNAME , FILE )
Description:
The fvscope function examines the compiled form of the
user-function, identified by FNAME, and prints a listing of
all the variables used within the function. Additionally the
scope of each variable is printed.
The second, and optional argument, is a string that denoted a
filename, or output process for fvscope to write it's output
to.
Fvscope is useful for writing general purpose functions that
will be used by others. It can be used to identify errant
global variables (variables that should be local, but were
overlooked).
Example:
> x = function ( y )
{
local (z)
z = 2*y + zz;
return z
}
<user-function>
> fvscope (x);
Function Variable SCOPE analysis for : x
Filename: stdin
line GLOBAL ARG LOCAL
1 Local-Var: z
1 Arg-Var: y
1 Global-Var: zz
1 Local-Var: z
The above example shows a trivial user-function, and the
output from fvscope. Notice the typo on the 5th line of the
function (`z = 2*y + zz;'), which should have read: `z = 2*y +
z;'. Fvscope identifies the variable `zz' as a global
variable, signaling the function author (who did not want to
use any global variables) that there is an error.
Also note that the line numbers in the above example are all
1. In this particular case (the function is entered at the
command line) this behavior is correct. When running fvscope()
on a function that is stored in a file, the proper line
numbers will be reported.